import Vue from 'vue'
import VueRouter from 'vue-router'
import asyncRouter from './async'

Vue.use(VueRouter)

const routes = []
const routesContexts = require.context('./routes', true, /\.js$/)
routesContexts.keys().forEach(name => routes.push(...routesContexts(name).default))

const router = new VueRouter({
  routes
})

// 设置异步路由
asyncRouter.router = router

export default router
